//
//@File    :	practice_3.2.cpp
//@Time    :	2021/09/20 21:39:58
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	
//

//编写一个小程序，要求以几英尺几英寸的方式输入其身高，
//并以磅为单位输入其体重。(使用3个变量来存储这些信息。）
//该程序报告其BMI (Body Mass Index，体重指数)。
//为了计算BMI，该程序以英寸的方式指出用户的身高(1英尺为12英寸)，
//并将以英寸为单位的身高转换为以米为单位的身高(1英寸=0.0254米)。
//然后，将以磅为单位的体重转换为以千克为单位的体重(1千克=2.2磅)。
//最后，计算相应的BMI——体重(千克）除以身高（米）的平方。
//用符号常量表示各种转换因子。

#include <iostream>

using namespace std;

int main()
{
    const int Inch_per_feet = 12;
    const double Meter_per_inch = 0.0254;
    const double Pound_per_kg = 2.2;
    
    int feet=0;
    int inch = 0;
    int weight_pound = 0;
    
    cout<<"Enter feet: ";
    cin>>feet;
    cout<<"Enter inches: ";
    cin>>inch;
    cout<<"Enter your weight: ";
    cin>>weight_pound;

    cout<<"Your height are: "<<feet<<" feet and "<<inch<<" inches."<<endl;
    cout<<"your weight in pounds: "<<weight_pound<<" pounds."<<endl;

    double height_meter=0.0;
    height_meter=(feet*Inch_per_feet+inch)*Meter_per_inch;
    double weight_kg=0.0;
    weight_kg=weight_pound/Pound_per_kg;
    cout<<"height in meter: "<<height_meter<<" meter and "<<weight_kg<<"kg."<<endl;

    double BMI=0.0;
    //or
    //double BMI(0.0);
    BMI=weight_kg/(height_meter*height_meter);
    cout<<"BMI is: "<<BMI;

    system("pause");
    return 0;
}